OutsideIn ( X ) Modular type inference with local assumptions 11 April 2011
نویسندگان
چکیده
Advanced type system features, such as GADTs, type classes, and type families, have proven to be invaluable language extensions for ensuring data invariants and program correctness. Unfortunately, they pose a tough problem for type inference when they are used as local type assumptions. Local type assumptions often result in the lack of principal types and cast the generalisation of local let-bindings prohibitively difficult to implement and specify. User-declared axioms only make this situation worse. In this article, we explain the problems and – perhaps controversially – argue for abandoning local let-binding generalisation. We give empirical results that local let generalisation is only sporadically used by Haskell programmers. Moving on, we present a novel constraint-based type inference approach for local type assumptions. Our system, called OutsideIn(X), is parameterised over the particular underlying constraint domain X, in the same way as HM(X). This stratification allows us to use a common metatheory and inference algorithm. OutsideIn(X) extends the constraints of X by introducing implication constraints on top. We describe the strategy for solving these implication constraints, which in turn relies on a constraint solver for X. We characterise the properties of the constraint solver for X so that the resulting algorithm only accepts programs with principal types, even when the type system specification accepts programs that do not enjoy principal types. Going beyond the general framework we give a particular constraint solver for X = type classes + GADTs + type families, a non-trivial challenge in its own right. This constraint solver has been implemented and distributed as part of GHC 7. 2 Vytiniotis, Peyton Jones, Schrijvers, Sulzmann
منابع مشابه
OutsideIn ( X ) Modular type inference with local assumptions 24 March 2011 Dimitrios
Advanced type system features, such as GADTs, type classes, and type families have proven to be invaluable language extensions for ensuring data invariants and program correctness among others. Unfortunately, they pose a tough problem for type inference, because they introduce local type assumptions. In this article we present a novel constraint-based type inference approach for local type assu...
متن کاملOutsideIn(X) Modular type inference with local assumptions
Advanced type system features, such as GADTs, type classes, and type families have have proven to be invaluable language extensions for ensuring data invariants and program correctness among others. Unfortunately, they pose a tough problem for type inference, because they introduce local type assumptions. In this article we present a novel constraint-based type inference approach for local type...
متن کاملPartial Type Signatures for Haskell
Strong type systems can be used to increase the reliability and performance of programs. In combination with type inference the overhead for the programmer can be kept small. Nevertheless, explicit type signatures often remain needed or useful. In languages with standard Hindley-Milner-based type systems, programmers have a binary choice between omitting the type signature (and rely on type inf...
متن کاملSome functional inequalities in variable exponent spaces with a more generalization of uniform continuity condition
Some functional inequalities in variable exponent Lebesgue spaces are presented. The bi-weighted modular inequality with variable exponent $p(.)$ for the Hardy operator restricted to non- increasing function which is$$int_0^infty (frac{1}{x}int_0^x f(t)dt)^{p(x)}v(x)dxleqCint_0^infty f(x)^{p(x)}u(x)dx,$$ is studied. We show that the exponent $p(.)$ for which these modular ine...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2011